package com.iflysse.dao;

import com.iflysse.pojo.po.req.TeachingClassIdPoReq;
import com.iflysse.pojo.po.resp.TeachingActivityPoResp;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

@Repository
public interface TeachingActivityDao {
    /**
     * 根据教学班级编号查询班级活动列表
     * @param teachingClassIdPoReq
     * @return
     */
    @Select("select task_id,task_name,update_time,task_expiration_date,task_state,'2' type from tb_task where teaching_class_id = #{teachingClassId} and is_delete = 0" +
            " UNION " +
            "select test_id,test_title,update_time,expiration_date,test_state,'1' type from tb_test WHERE teaching_class_id =#{teachingClassId} and is_delete = 0" +
            " ORDER BY update_time desc")
    @Results({
            @Result(property = "activityId",column = "task_id"),
            @Result(property = "activityTitle",column = "task_name"),
            @Result(property = "updateTime",column = "update_time"),
            @Result(property = "expirationDate",column = "task_expiration_date"),
            @Result(property = "state",column = "task_state"),
    })
    List<TeachingActivityPoResp> getActivitiesByTeachingClassId(TeachingClassIdPoReq teachingClassIdPoReq) throws SQLException;
}
